package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * 61.3 域 PVV 校验结果<p>
 * 当入网机构需要银联处理中心代为验证PVV时，该域存放银联处理中心的校验结果。<br>
 * 当入网机构无需银联处理中心代为验证PVV时，该域以空格填充<br>
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F61_3_PVVCheckRsltEnum {
    _1("1", "成功"),
    _2("2", "失败"),
    _3("3", "未校验"),
    ;

    private String code;
    private String desc;

    F61_3_PVVCheckRsltEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F61_3_PVVCheckRsltEnum find(String code) {
        F61_3_PVVCheckRsltEnum result = Arrays.stream(F61_3_PVVCheckRsltEnum.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
